home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / INCLUDE / VGAMOUSE.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  6KB  |  182 lines

  1. /* Mouse interface for svgalib. */
  2. /* Can be used independently. */
  3.  
  4. #ifndef VGAMOUSE_H
  5. #define VGAMOUSE_H
  6.  
  7. #ifdef __cplusplus
  8. extern "C"
  9. {
  10. #endif
  11.  
  12. #define    MOUSE_MICROSOFT 0
  13. #define MOUSE_MOUSESYSTEMS 1
  14. #define MOUSE_MMSERIES 2
  15. #define MOUSE_LOGITECH 3
  16. #define MOUSE_BUSMOUSE 4
  17. #define MOUSE_PS2 5
  18. #define MOUSE_LOGIMAN 6
  19. #define MOUSE_GPM 7
  20. #define MOUSE_SPACEBALL 8
  21. #define MOUSE_NONE 9         /* Some special number for a non supported/existing mouse */
  22. #define MOUSE_INTELLIMOUSE 10
  23. #define MOUSE_IMPS2 11
  24.  
  25. #define MOUSE_ORIENTATION_VERTICAL 0
  26. #define MOUSE_ORIENTATION_HORIZONTAL 1
  27.  
  28. #define MOUSE_ACCEL_TYPE_NORMAL 1
  29. #define MOUSE_ACCEL_TYPE_POWER  2
  30.  
  31. #define DEFAULT_ACCEL_THRESH    5
  32. #define DEFAULT_ACCEL_POWER    1.2
  33. #define DEFAULT_ACCEL_OFFSET    1
  34. #define DEFAULT_ACCEL_MULT    10
  35. #define DEFAULT_MAXDELTA    0
  36. #define DEFAULT_ACCEL_MAXDELTA    0
  37. #define DEFAULT_ACCEL_TYPE    0    /* MOUSE_ACCEL_TYPE_POWER */
  38.  
  39. /* MS IntelliMouse has 18 steps, Logitech FirstMouse+ has 24 */
  40. #define DEFAULT_WHEEL_STEPS     18
  41. #define DEFAULT_WHEEL_DELTA     (360 / DEFAULT_WHEEL_STEPS)
  42.  
  43. /* Logical or the following values to one of the above at will and give that for
  44.    type in mouse_init (still they make only sense for serial mice) */
  45.  
  46. #define MOUSE_CHG_DTR    0x80000000    /* CLEAR (!) the DTR line */
  47. #define MOUSE_DTR_HIGH    0x40000000    /* when used with MOUSE_CHG_DTR set DTR not clear it */
  48. #define MOUSE_CHG_RTS    0x20000000    /* CLEAR (!) the RTS line */
  49. #define MOUSE_RTS_HIGH    0x10000000    /* when used with MOUSE_CHG_RTS set RTS not clear it */
  50.  
  51. /* If MOUSE_CHG_DTR is not given the DTR state is not touched.. same with RTS resp. */
  52. /* So I use MOUSE_MOUSESYSTEMS|MOUSE_CHG_RTS to force my
  53.    multiprotocol mouse to MOUSESYSTEMS and use init the driver to MOUSESYSTEMS */
  54.  
  55. #define MOUSE_TYPE_MASK 0xffff    /* the upper 16bit are reserved for future flags */
  56.  
  57. #define MOUSE_LEFTBUTTON 4
  58. #define MOUSE_MIDDLEBUTTON 2
  59. #define MOUSE_RIGHTBUTTON 1
  60. #define MOUSE_FOURTHBUTTON 8
  61. #define MOUSE_FIFTHBUTTON 16
  62. #define MOUSE_SIXTHBUTTON 32
  63. #define MOUSE_RESETBUTTON 64
  64.  
  65. #define MOUSE_XDIM 1
  66. #define MOUSE_YDIM 2
  67. #define MOUSE_ZDIM 4
  68. #define MOUSE_RXDIM 8
  69. #define MOUSE_RYDIM 16
  70. #define MOUSE_RZDIM 32
  71. #define MOUSE_2DIM 3
  72. #define MOUSE_3DIM 7
  73. #define MOUSE_6DIM 63
  74.  
  75. #define MOUSE_DEFAULTSAMPLERATE 150
  76.  
  77. /* Initialize mouse device. Returns 0 if succesful, -1 otherwise. */
  78. /* (Get the svgalib configured type with vga_getmousetype()). */
  79.     int mouse_init(char *dev, int type, int samplerate);
  80. /* Similar but returns the mouse fd if succesful. */
  81.     int mouse_init_return_fd(char *dev, int type, int samplerate);
  82. /* Set event handler invoked by mouse_update(). */
  83. #if 0 /* This is the actual definition */
  84.     typedef void (*__mouse_handler) (int button, int dx, int dy, int dz,
  85.                                      int drx, int dry, int drz);
  86. #else /* For backwards compatibility with:
  87.         typedef void (*__mouse_handler) (int button, int dx, int dy) we use: */
  88.     typedef void *__mouse_handler;
  89. #endif
  90.     void mouse_seteventhandler(__mouse_handler handler);
  91. /* Close mouse device. */
  92.     void mouse_close(void);
  93. /* Read mouse and handle events. Returns 0 if no event. */
  94.     int mouse_update(void);
  95. /* Similar to mouse_update, but wait for an event to happen. */
  96.     void mouse_waitforupdate(void);
  97.  
  98. /* mouse_init sets default event handler that keeps track of absolute */
  99. /* coordinates: */
  100.  
  101. #define MOUSE_NOWRAP 0
  102. #define MOUSE_WRAPX 1
  103. #define MOUSE_WRAPY 2
  104. #define MOUSE_WRAPZ 4
  105. #define MOUSE_WRAPRX 8
  106. #define MOUSE_WRAPRY 16
  107. #define MOUSE_WRAPRZ 32
  108. #define MOUSE_WRAP 63
  109. #define MOUSE_ROT_COORDS 196
  110. #define MOUSE_ROT_INFINITESIMAL 0 /* report changes in angle about axes */
  111. #define MOUSE_ROT_RX_RY_RZ 64     /* report angle about axes */
  112.  
  113. /* Warning! Next two not yet supported! */
  114. #define MOUSE_ROT_ZXZ 128      /* use x convention Euler angles */
  115. #define MOUSE_ROT_YPR 196      /* use yaw, pitch, and roll */
  116.  
  117. /* Revert to default handler. */
  118.     void mouse_setdefaulteventhandler(void);
  119. /* Set position of mouse. */
  120.     void mouse_setposition(int x, int y);
  121. /* Set position of mouse in all 6 dimensions. */
  122.     void mouse_setposition_6d(int x, int y, int z,
  123.                               int rx, int ry, int rz, int dim_mask);
  124. /* Set horizontal range of mouse to [x1, x2] incl. */
  125.     void mouse_setxrange(int x1, int x2);
  126. /* Set vertical range of mouse to [y1, y2] incl. */
  127.     void mouse_setyrange(int y1, int y2);
  128. /* Set all ranges of mouse in 6 dimensions. */
  129.     void mouse_setrange_6d(int x1, int x2, int y1, int y2, int z1, int z2,
  130.            int rx1, int rx2, int ry1, int ry2, int rz1, int rz2, int dim_mask);
  131. /* Set scale factor by which raw mouse coordinates are divided. */
  132.     void mouse_setscale(int s);
  133. /* Enable/disable wrapping of mouse in horizontal and/or vertical range. */
  134.     void mouse_setwrap(int w);
  135.  
  136. /* Get current mouse x-coordinate. */
  137.     int mouse_getx(void);
  138. /* Get current mouse y-coordinate. */
  139.     int mouse_gety(void);
  140. /* Get position of mouse in all 6 dimensions. */
  141.     void mouse_getposition_6d(int *x, int *y, int *z,
  142.                               int *rx, int *ry, int *rz);
  143. /* Get current mouse button status. */
  144.     int mouse_getbutton(void);
  145.  
  146.  
  147. #define MOUSE_CAPS     1024
  148. #define MOUSE_WANTCAPS 0x002b0042
  149. #define MOUSE_GOTCAPS  0x0042ffd4
  150.  
  151. #define MOUSE_INFO_WHEEL 0x00000001 /* The mouse has a wheel */
  152.  
  153.     struct MouseCaps {
  154.         int key;       /* MOUSE_GOTCAPS */
  155.         int buttons;   /* MOUSE_*BUTTON */
  156.         int axes;      /* MOUSE_*DIM */
  157.         int info;      /* MOUSE_INFO_* */
  158.         int reserved0; /* Don't use these! */
  159.         int reserved1; /* The names may change in the future... */
  160.     };
  161.  
  162. /* Use this function to get information about the mouse without depending on
  163.  mouse types known when your app was made. The weirdness is so that you
  164.  don't need to depend on having svgalib 1.3.0; as long as you don't depend
  165.  on other features your app should be able to work with older versions too,
  166.  just without this info... In a future version this will be made a real
  167.  function. Returns 0 on success or -1 on failure. */
  168.  
  169.     static inline int mouse_getcaps(struct MouseCaps *caps)
  170.     {
  171.         mouse_setposition_6d(MOUSE_WANTCAPS,0,0, 0,0,0, MOUSE_CAPS);
  172.         mouse_getposition_6d(&(caps->key), &(caps->buttons), &(caps->axes),
  173.                              &(caps->info), &(caps->reserved0), &(caps->reserved1));
  174.         return ((caps->key == MOUSE_GOTCAPS) ? (0) : (-1));
  175.     }
  176.  
  177. #ifdef __cplusplus
  178. }
  179.  
  180. #endif
  181. #endif
  182.